home *** CD-ROM | disk | FTP | other *** search
/ Internet Pratica / IPRAT_01.iso / ASP / ASPapp Portal / admin_content.asp < prev    next >
Encoding:
Text File  |  2002-03-13  |  23.3 KB  |  727 lines

  1. <!-- #include file="i_utils.asp" -->
  2. <%
  3.  
  4. check_security(2) 
  5.  
  6. %>
  7. <%
  8.     dim ContentID
  9.     dim user_id
  10.     dim ContentTypeID
  11.     dim CatID
  12.     dim Title
  13.     dim Author
  14.     dim RelatedURL
  15.     dim DownloadURL
  16.     dim FileName
  17.     dim DateAdded
  18.     dim ShortDesc
  19.     dim LongDesc
  20.     dim Display
  21.     dim EMail
  22.     dim Expire
  23.     dim Priority
  24.     dim Impressions
  25.     dim ClickThrus
  26.     dim AvgRating
  27.     dim Ratings
  28.     dim edit_content_sql
  29.     dim ContentType
  30.     dim Cat
  31.     dim view_content_sql
  32.  
  33. sub request_edit_content
  34. ''' request expected input parameters for this form
  35.     ContentID = request("ContentID")
  36.     user_id = request("user_id")
  37.     ContentTypeID = request("ContentTypeID")
  38.     CatID = request("CatID")
  39.     Title = request("Title")
  40.     Author = request("Author")
  41.     RelatedURL = request("RelatedURL")
  42.     DownloadURL = request("DownloadURL")
  43.     FileName = request("FileName")
  44.     DateAdded = request("DateAdded")
  45.     ShortDesc = request("ShortDesc")
  46.     LongDesc = request("LongDesc")
  47.     Display = request("Display")
  48.     EMail = request("EMail")
  49.     Expire = request("Expire")
  50.     Priority = request("Priority")
  51.     Impressions = request("Impressions")
  52.     ClickThrus = request("ClickThrus")
  53.     AvgRating = request("AvgRating")
  54.     Ratings = request("Ratings")
  55. end sub
  56. sub request_view_content
  57. ''' request expected input parameters for this form
  58.     CatID = request("CatID")
  59.     ContentTypeID = request("ContentTypeID")
  60.     user_id = request("user_id")
  61.     ContentID = request("ContentID")
  62.     ContentType = request("ContentType")
  63.     Cat = request("Cat")
  64.     Title = request("Title")
  65.     Author = request("Author")
  66.     DateAdded = request("DateAdded")
  67.     ShortDesc = request("ShortDesc")
  68.     Display = request("Display")
  69.     Priority = request("Priority")
  70.     Impressions = request("Impressions")
  71.     ClickThrus = request("ClickThrus")
  72.     AvgRating = request("AvgRating")
  73. end sub
  74.  
  75. sub validate_edit_content
  76. ''' request and validate data entered from this form
  77.     ContentID = trim(request("ContentID"))
  78.     user_id = trim(request("user_id"))
  79.     if user_id = "" then
  80.         error_list.add "487963","User must be specified."
  81.         b_error = true
  82.     end if
  83.     ContentTypeID = trim(request("ContentTypeID"))
  84.     if ContentTypeID = "" then
  85.         error_list.add "487950","Content Type must be specified."
  86.         b_error = true
  87.     end if
  88.     CatID = trim(request("CatID"))
  89.     if CatID = "" then
  90.         error_list.add "487947","Category must be specified."
  91.         b_error = true
  92.     end if
  93.     Title = trim(request("Title"))
  94.     if Title = "" then
  95.         error_list.add "487962","Title must be specified."
  96.         b_error = true
  97.     end if
  98.     Author = trim(request("Author"))
  99.     RelatedURL = trim(request("RelatedURL"))
  100.     DownloadURL = trim(request("DownloadURL"))
  101.     FileName = trim(request("FileName"))
  102.     DateAdded = trim(request("DateAdded"))
  103.     if DateAdded <> "" AND (not isdate(DateAdded)) then
  104.         error_list.add "487951date","Date Added must be a valid date (MM/DD/YY)."
  105.         b_error = true
  106.     end if
  107.     ShortDesc = trim(request("ShortDesc"))
  108.     if ShortDesc = "" then
  109.         error_list.add "487961","Description must be specified."
  110.         b_error = true
  111.     end if
  112.     LongDesc = trim(request("LongDesc"))
  113.     Display = trim(request("Display"))
  114.     EMail = trim(request("EMail"))
  115.     Expire = trim(request("Expire"))
  116.     if Expire <> "" AND (not isdate(Expire)) then
  117.         error_list.add "487955date","Expire must be a valid date (MM/DD/YY)."
  118.         b_error = true
  119.     end if
  120.     Priority = trim(request("Priority"))
  121.     if Priority = "" then
  122.         error_list.add "487958","Priority must be specified."
  123.         b_error = true
  124.     end if
  125.     Impressions = trim(request("Impressions"))
  126.     ClickThrus = trim(request("ClickThrus"))
  127.     AvgRating = trim(request("AvgRating"))
  128.     Ratings = trim(request("Ratings"))
  129. end sub
  130. sub validate_view_content
  131. ''' request and validate data entered from this form
  132.     CatID = trim(request("CatID"))
  133.     ContentTypeID = trim(request("ContentTypeID"))
  134.     user_id = trim(request("user_id"))
  135.     ContentID = trim(request("ContentID"))
  136.     ContentType = trim(request("ContentType"))
  137.     Cat = trim(request("Cat"))
  138.     Title = trim(request("Title"))
  139.     Author = trim(request("Author"))
  140.     DateAdded = trim(request("DateAdded"))
  141.     if DateAdded <> "" AND (not isdate(DateAdded)) then
  142.         error_list.add "487978date","Created must be a valid date (MM/DD/YY)."
  143.         b_error = true
  144.     end if
  145.     ShortDesc = trim(request("ShortDesc"))
  146.     Display = trim(request("Display"))
  147.     Priority = trim(request("Priority"))
  148.     Impressions = trim(request("Impressions"))
  149.     ClickThrus = trim(request("ClickThrus"))
  150.     AvgRating = trim(request("AvgRating"))
  151. end sub
  152.  
  153. sub get_defaults_edit_content
  154. ''' set default values for this form
  155.     DateAdded = "" & now() & ""
  156.     Display = 1
  157.     Priority = 1
  158.     Impressions = 0
  159.     ClickThrus = 0
  160.     Ratings = 0
  161. end sub
  162. sub get_defaults_view_content
  163. ''' set default values for this form
  164.     Display = 1
  165. end sub
  166.  
  167. sub db_select_edit_Content
  168.     sql = "SELECT " & _ 
  169.     "ContentID, " & _ 
  170.     "user_id, " & _ 
  171.     "ContentTypeID, " & _ 
  172.     "CatID, " & _ 
  173.     "Title, " & _ 
  174.     "Author, " & _ 
  175.     "RelatedURL, " & _ 
  176.     "DownloadURL, " & _ 
  177.     "FileName, " & _ 
  178.     "DateAdded, " & _ 
  179.     "ShortDesc, " & _ 
  180.     "LongDesc, " & _ 
  181.     "Display, " & _ 
  182.     "EMail, " & _ 
  183.     "Expire, " & _ 
  184.     "Priority, " & _ 
  185.     "Impressions, " & _ 
  186.     "ClickThrus, " & _ 
  187.     "AvgRating, " & _ 
  188.     "Ratings FROM Content" & _ 
  189.     " WHERE " & _ 
  190.     "Content.ContentID = " & to_sql(ContentID,"number") & ""
  191.     on error resume next
  192.     set rs = cn.Execute(sql)
  193.     if err.number <> 0 then
  194.         b_error = true
  195.         error_list.add "select_data_edit_Content", "The data selection failed. " & err.description
  196.     elseif rs.EOF then
  197.         b_results = false
  198.         msg_list.add "select_data_edit_Content", "The record was removed from the database."
  199.     else
  200.         ContentID = rs("ContentID")
  201.         user_id = rs("user_id")
  202.         ContentTypeID = rs("ContentTypeID")
  203.         CatID = rs("CatID")
  204.         Title = rs("Title")
  205.         Author = rs("Author")
  206.         RelatedURL = rs("RelatedURL")
  207.         DownloadURL = rs("DownloadURL")
  208.         FileName = rs("FileName")
  209.         DateAdded = rs("DateAdded")
  210.         ShortDesc = rs("ShortDesc")
  211.         LongDesc = rs("LongDesc")
  212.         Display = rs("Display")
  213.         EMail = rs("EMail")
  214.         Expire = rs("Expire")
  215.         Priority = rs("Priority")
  216.         Impressions = rs("Impressions")
  217.         ClickThrus = rs("ClickThrus")
  218.         AvgRating = rs("AvgRating")
  219.         Ratings = rs("Ratings")
  220.     end if
  221.     rs.Close
  222.     on error goto 0
  223. end sub
  224. sub db_insert_edit_Content
  225.     sql = "INSERT INTO Content" & _ 
  226.     "(" & _ 
  227.     "user_id," & _ 
  228.     "ContentTypeID," & _ 
  229.     "CatID," & _ 
  230.     "Title," & _ 
  231.     "Author," & _ 
  232.     "FileName," & _ 
  233.     "RelatedURL," & _ 
  234.     "DownloadURL," & _ 
  235.     "DateAdded," & _ 
  236.     "ShortDesc," & _ 
  237.     "LongDesc," & _ 
  238.     "Display," & _ 
  239.     "EMail," & _ 
  240.     "Expire," & _ 
  241.     "Priority," & _ 
  242.     "Impressions," & _ 
  243.     "ClickThrus," & _ 
  244.     "AvgRating," & _ 
  245.     "Ratings" & _ 
  246.     ") VALUES (" & _ 
  247.     "" & to_sql(user_id,"number") & "," & _ 
  248.     "" & to_sql(ContentTypeID,"number") & "," & _ 
  249.     "" & to_sql(CatID,"number") & "," & _ 
  250.     "" & to_sql(Title,"text") & "," & _ 
  251.     "" & to_sql(Author,"text") & "," & _ 
  252.     "" & to_sql(FileName,"text") & "," & _ 
  253.     "" & to_sql(RelatedURL,"text") & "," & _ 
  254.     "" & to_sql(DownloadURL,"text") & "," & _ 
  255.     "" & to_sql(now(),"date") & "," & _ 
  256.     "" & to_sql(ShortDesc,"text") & "," & _ 
  257.     "" & to_sql(LongDesc,"text") & "," & _ 
  258.     "" & to_sql(Display,"number") & "," & _ 
  259.     "" & to_sql(EMail,"text") & "," & _ 
  260.     "" & to_sql(Expire,"text") & "," & _ 
  261.     "" & to_sql(Priority,"number") & "," & _ 
  262.     "" & to_sql(Impressions,"number") & "," & _ 
  263.     "" & to_sql(ClickThrus,"number") & "," & _ 
  264.     "" & to_sql(AvgRating,"text") & "," & _ 
  265.     "" & to_sql(Ratings,"number") & ")" & _ 
  266.     ""
  267.     'response.write sql
  268.     on error resume next
  269.     cn.Execute(sql)
  270.     if err.Number <> 0 then
  271.         b_error = true
  272.         error_list.add "db_insert_edit_Content" & err.Number ,"The database insert failed. " & err.Description
  273.     else
  274.         set rs = cn.Execute("SELECT @@IDENTITY")
  275.         ContentID = rs(0)
  276.         rs.Close
  277.         msg_list.add "db_insert_edit_Content","The database insert was successful."    end if
  278.     on error goto 0
  279. end sub
  280. sub db_update_edit_Content
  281.     sql = "UPDATE Content SET " & _ 
  282.     "user_id = " & to_sql(user_id,"number") & ", " & _ 
  283.     "ContentTypeID = " & to_sql(ContentTypeID,"number") & ", " & _ 
  284.     "CatID = " & to_sql(CatID,"number") & ", " & _ 
  285.     "Title = " & to_sql(Title,"text") & ", " & _ 
  286.     "Author = " & to_sql(Author,"text") & ", " & _ 
  287.     "FileName = " & to_sql(FileName,"text") & ", " & _ 
  288.     "RelatedURL = " & to_sql(RelatedURL,"text") & ", " & _ 
  289.     "DownloadURL = " & to_sql(DownloadURL,"text") & ", " & _ 
  290.     "DateAdded = " & to_sql(DateAdded,"text") & ", " & _ 
  291.     "ShortDesc = " & to_sql(ShortDesc,"text") & ", " & _ 
  292.     "LongDesc = " & to_sql(LongDesc,"text") & ", " & _ 
  293.     "Display = " & to_sql(Display,"number") & ", " & _ 
  294.     "EMail = " & to_sql(EMail,"text") & ", " & _ 
  295.     "Expire = " & to_sql(Expire,"text") & ", " & _ 
  296.     "Priority = " & to_sql(Priority,"number") & ", " & _ 
  297.     "Impressions = " & to_sql(Impressions,"number") & ", " & _ 
  298.     "ClickThrus = " & to_sql(ClickThrus,"number") & ", " & _ 
  299.     "AvgRating = " & to_sql(AvgRating,"text") & ", " & _ 
  300.     "Ratings = " & to_sql(Ratings,"number") & " WHERE " & _ 
  301.     "ContentID = " & ContentID & ""
  302.     'response.write sql
  303.     on error resume next
  304.     cn.execute(sql)
  305.     if err.number <> 0 then
  306.         b_error = true
  307.         error_list.add "db_update_edit_Content" & err.Number ,"The database update failed. " & err.Description
  308.     else
  309.         msg_list.add "db_update_edit_Content" & ContentID,"The database update was successful."
  310.     end if
  311.     on error goto 0
  312. end sub
  313. sub db_delete_edit_Content
  314.     sql = "DELETE FROM Content" & _ 
  315.     " WHERE " & _ 
  316.     "ContentID = " & to_sql(ContentID,"number") & ""
  317.     'response.write sql
  318.     on error resume next
  319.     cn.Execute(sql)
  320.     if err.number <> 0 then
  321.         b_error = true
  322.         error_list.add "db_delete_edit_Content" & err.Number ,"The database deletion failed. " & err.Description
  323.     else
  324.         msg_list.add "db_delete_edit_Content","The record was removed."
  325.     end if
  326.     on error goto 0
  327. end sub
  328. sub db_select_view_Content
  329.     view_Content_sql = "SELECT " & _ 
  330.     "Content.ContentID, " & _ 
  331.     "Content.user_id, " & _ 
  332.     "Content.RegionID, " & _ 
  333.     "Content.ContentTypeID, " & _ 
  334.     "Content.CatID, " & _ 
  335.     "Content.Title, " & _ 
  336.     "Content.Author, " & _ 
  337.     "Content.FileName, " & _ 
  338.     "Content.RelatedURL, " & _ 
  339.     "Content.DownloadURL, " & _ 
  340.     "Content.DateAdded, " & _ 
  341.     "Content.ShortDesc, " & _ 
  342.     "Content.LongDesc, " & _ 
  343.     "Content.Display, " & _ 
  344.     "Content.EMail, " & _ 
  345.     "Content.Expire, " & _ 
  346.     "Content.Priority, " & _ 
  347.     "Content.Impressions, " & _ 
  348.     "Content.ClickThrus, " & _ 
  349.     "Content.AvgRating, " & _ 
  350.     "Content.Ratings, " & _ 
  351.     "ContentTypes.ContentType, Cats.Cat FROM ((Content LEFT JOIN ContentTypes ON Content.ContentTypeID = ContentTypes.ContentTypeID) LEFT JOIN Cats ON Content.CatId = Cats.CatId)"
  352.     if request("sortby") <> "" AND inStr(lcase(view_Content_sql),"order by") = 0 then view_Content_sql = view_Content_sql + " ORDER BY " & request("sortby")
  353. end sub
  354. sub db_delete_view_Content
  355.     sql = "DELETE FROM " & _ 
  356.     ""
  357.     'response.write sql
  358.     on error resume next
  359.     cn.Execute(sql)
  360.     if err.number <> 0 then
  361.         b_error = true
  362.     end if
  363.     on error goto 0
  364. end sub
  365.  
  366. do_search = request("do_search")
  367. ''' request form keys
  368. ContentID = request("ContentID")
  369. ''' request action
  370. action = lcase(request("action"))
  371. ''' action case handler
  372. select case action
  373.  
  374. case "select_edit_content"
  375. '  select the requested key record from database
  376. if ContentID <> "" then
  377.     db_select_edit_Content
  378. else
  379.     b_error = true
  380.     error_list.add "edit_edit_Content", "Specify record to select."
  381. end if
  382.  
  383.  
  384. case "insert_edit_content"
  385. '  request form data and insert a new record into database
  386.  
  387. validate_edit_content
  388. if not b_error then
  389.     ''' form validation passed, so save record
  390.     db_insert_edit_content
  391. else
  392.     ''' form validation failed, so re-display form
  393.     display_edit_content = true 
  394. end if
  395.  
  396.  
  397.  
  398.  
  399. case "update_edit_content"
  400. '  request form data and update an existing database record
  401. validate_edit_content
  402. if not b_error then
  403. if ContentID <> "" then
  404.     db_update_edit_content
  405. else
  406.     b_error = true
  407.     error_list.add "update_edit_content", "Specify record to update."
  408. end if
  409. end if
  410.  
  411.  
  412. case "delete_edit_content"
  413. '  delete the requested key database record
  414. if ContentID <> "" then
  415.     db_delete_edit_content
  416.     response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted."
  417. else
  418.     b_error = true
  419.     error_list.add "delete_edit_content", "Specify record to delete."
  420. end if
  421.  
  422. case "display_edit_content"
  423.     display_edit_content = true
  424.  
  425. end select
  426.  
  427. '  no action was specified, so handle the default case(s)
  428. if ContentID <> "" then
  429.     db_select_edit_Content
  430.     display_edit_Content = true 
  431. end if
  432.  
  433. ':: list all content
  434. db_select_view_Content
  435.  
  436. %>
  437.  
  438. <!-- #include file='i_header.asp' -->
  439. <!-- #include file='i_menu.asp' -->
  440.  
  441. <!-- #include file="i_menu_admin.asp" -->
  442. <%
  443. display_errs
  444. display_msg
  445. %>
  446.  
  447. <br>
  448. <! -- only display the edit form when the grid form is not displayed -->
  449. <% if ContentID <> "" OR display_edit_content then %>[<A HREF='admin_content.asp'>view all</A>]
  450. <table class='headerTable'>
  451. <tr>
  452. <td class='headerTD'>
  453. Edit Content
  454. </td>
  455. </tr>
  456. </table>
  457. <table  >
  458. <form name="edit_Content" action="admin_content.asp" method="post" >
  459.         
  460.         <input type=hidden name="ContentID" value="<% =ContentID %>">
  461.         
  462. <tr>
  463.     <td class='labelTD'>User</td>
  464.     <td class='dataTD' >
  465.         
  466.         <select name="user_id" >
  467.         <option></option>
  468.         <%
  469.          =get_options ("SELECT user_id, user_name FROM Users", user_id) 
  470.         %>
  471.         </select>
  472.         
  473.     </td>
  474. </tr>
  475. <tr>
  476.     <td class='labelTD'>Content Type</td>
  477.     <td class='dataTD' >
  478.         
  479.         <select name="ContentTypeID" >
  480.         <option></option>
  481.         <%
  482.          =get_options ("SELECT ContentTypeID, ContentType FROM ContentTypes", ContentTypeID) 
  483.         %>
  484.         </select>
  485.         <A href='admin_contenttypes.asp'>Edit Types..</A>
  486.     </td>
  487. </tr>
  488. <tr>
  489.     <td class='labelTD'>Category</td>
  490.     <td class='dataTD' >
  491.         
  492.         <select name="CatID" >
  493.         <option></option>
  494.         <%
  495.          =get_options ("SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) left JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats.ParentId is NULL order by (Cats.Cat & Cats1.Cat & Cats2.Cat & Cats3.Cat)", CatID) 
  496.         %>
  497.         </select>
  498.         
  499.     </td>
  500. </tr>
  501. <tr>
  502.     <td class='labelTD'>Title</td>
  503.     <td class='dataTD' >
  504.         <input type=text  name="Title" size="" maxlength="50" value="<% =Title%>">
  505.     </td>
  506. </tr>
  507. <tr>
  508.     <td class='labelTD'>Author</td>
  509.     <td class='dataTD' >
  510.         <input type=text  name="Author" size="" maxlength="50" value="<% =Author%>">
  511.     </td>
  512. </tr>
  513. <tr>
  514.     <td class='labelTD'>Related URL</td>
  515.     <td class='dataTD' >
  516.         <input type=text  name="RelatedURL" size="" maxlength="70" value="<% =RelatedURL%>">
  517.     </td>
  518. </tr>
  519. <tr>
  520.     <td class='labelTD'>Download URL</td>
  521.     <td class='dataTD' >
  522.         <input type=text  name="DownloadURL" size="" maxlength="50" value="<% =DownloadURL%>">
  523.     </td>
  524. </tr>
  525. <tr>
  526.     <td class='labelTD'>Filename</td>
  527.     <td class='dataTD' >
  528.         <input type=text  name="FileName" size="" maxlength="" value="<% =FileName%>">
  529.     </td>
  530. </tr>
  531. <tr>
  532.     <td class='labelTD'>Date Added</td>
  533.     <td class='dataTD' >
  534.         <% =DateAdded %>
  535.     </td>
  536. </tr>
  537. <tr>
  538.     <td class='labelTD'>Description</td>
  539.     <td class='dataTD' >
  540.         
  541.         <textarea  name="ShortDesc" rows='6' cols='50'><% =ShortDesc%></textarea>
  542.         
  543.     </td>
  544. </tr>
  545. <tr>
  546.     <td class='labelTD'>Content</td>
  547.     <td class='dataTD' >
  548.         
  549.         <textarea  name="LongDesc" rows='20' cols='90'><% =LongDesc%></textarea>
  550.         
  551.     </td>
  552. </tr>
  553. <tr>
  554.     <td class='labelTD'>Display</td>
  555.     <td class='dataTD' >
  556.         <% if Display = "" then Display = false %>
  557.         <input type=checkbox  <% if Display then %>checked<% end if %> name="Display" value="1">
  558.     </td>
  559. </tr>
  560. <tr>
  561.     <td class='labelTD'>EMail</td>
  562.     <td class='dataTD' >
  563.         <input type=text  name="EMail" size="" maxlength="50" value="<% =EMail%>">
  564.     </td>
  565. </tr>
  566. <tr>
  567.     <td class='labelTD'>Expire</td>
  568.     <td class='dataTD' >
  569.         <input type=text  name="Expire" size="" maxlength="10" value="<% =Expire%>">
  570.     </td>
  571. </tr>
  572. <tr>
  573.     <td class='labelTD'>Priority</td>
  574.     <td class='dataTD' >
  575.     <%
  576.     if not isnull(Priority) then
  577.          if (Priority < 1) AND (not Priority) then Priority = 0
  578.     else
  579.         Priority = 0
  580.     end if
  581.     %>
  582.         
  583.         <select name="Priority" >
  584.         <option></option>
  585.         <option <% if "1" = cStr(Priority) then %>selected<% end if %> value="1">1-standard</option>
  586.         <option <% if "2" = cStr(Priority) then %>selected<% end if %> value="2">2-priority</option>
  587.         <option <% if "3" = cStr(Priority) then %>selected<% end if %> value="3">3-premier</option>
  588.         </select>
  589.         
  590.     </td>
  591. </tr>
  592. <tr>
  593.     <td class='labelTD'>Impressions</td>
  594.     <td class='dataTD' >
  595.         <% =Impressions %>
  596.     </td>
  597. </tr>
  598. <tr>
  599.     <td class='labelTD'>Click-thrus</td>
  600.     <td class='dataTD' >
  601.         <% =ClickThrus %>
  602.     </td>
  603. </tr>
  604. <tr>
  605.     <td class='labelTD'>Avg Rating</td>
  606.     <td class='dataTD' >
  607.         <% =AvgRating %>
  608.     </td>
  609. </tr>
  610. <tr>
  611.     <td class='labelTD'>Ratings</td>
  612.     <td class='dataTD' >
  613.         <% =Ratings %>
  614.     </td>
  615. </tr>
  616. <tr>
  617.     <td class=labelTD align=right> 
  618.     <% if ContentID <> "" then %><% end if %>
  619.     </td>
  620.     <td class=dataTD>
  621.     <% if ContentID = "" then %><input type=submit name=insert_button value='INSERT'><% end if %>
  622.     <% if ContentID <> "" then %><input type=submit name=update_button value='UPDATE'><% end if %>
  623.     <% if ContentID <> "" then %><input type=submit name=delete_button value='DELETE' onclick="document.edit_Content.action.value = 'delete_edit_Content'"><% end if %>
  624.     </td>
  625. <input type=hidden name="action" value="<% if ContentID <> "" then %>update<% else %>insert<%end if %>_edit_Content"></tr>
  626.  
  627. </form>
  628. </table>
  629.  
  630. <% end if %>
  631. <! -- only display the grid when the edit form is not displayed -->
  632. <br>
  633. <% if display_edit_Content <> true then %>[<A HREF='admin_content.asp?action=display_edit_Content'>add new article</A>]
  634. <%
  635.  
  636. page_no = request("page_no")
  637. if page_no = "" then page_no = 1
  638.  
  639. if view_Content_sql <> "" then
  640.     cmd.CommandText = view_Content_sql
  641.     rs.Filter = ""
  642.     rs.CursorLocation = 3
  643.     rs.CacheSize = 5
  644.     rs.Open cmd
  645.     if not rs.EOF then
  646.             rs.MoveFirst
  647.             rs.PageSize = 20
  648.             max_count = cInt(rs.PageCount)
  649.             num_recs = rs.RecordCount
  650.             rs.AbsolutePage = page_no
  651.             results = true
  652.     else
  653.         results = false
  654.         rs.Close
  655.     end if
  656. else
  657.     results = false
  658. end if
  659. rec_count = 0
  660.  
  661. %>
  662.  
  663. <table class='headerTable'>
  664. <tr>
  665. <td class='headerTD'>
  666. Existing Content
  667. </td>
  668. </tr>
  669. </table>
  670. <%
  671.  
  672. if results = true then
  673.  
  674. %>
  675.  
  676. <table  >
  677. <form name="view_Content" action="admin_content.asp" method="get" >
  678. <tr>
  679.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ContentID" class=fieldFont title="">#</a></td>
  680.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ContentType" class=fieldFont title="">Content Type</a></td>
  681.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Cat" class=fieldFont title="">Category</a></td>
  682.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Title" class=fieldFont title="">Title</a></td>
  683.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Author" class=fieldFont title="">Author</a></td>
  684.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=DateAdded" class=fieldFont title="">Created</a></td>
  685.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ShortDesc" class=fieldFont title="">Description</a></td>
  686.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Display" class=fieldFont title="">Display</a></td>
  687.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Priority" class=fieldFont title="">Priority</a></td>
  688.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Impressions" class=fieldFont title="">Views</a></td>
  689.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ClickThrus" class=fieldFont title="">Clicks</a></td>
  690.     <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=AvgRating" class=fieldFont title="">Rating</a></td>
  691. </tr>
  692. <%
  693.  
  694. do while not rs.EOF AND (rec_count < rs.Pagesize)
  695.  
  696. ':: read db record
  697. on error resume next
  698. CatID = rs("CatID")
  699. ContentTypeID = rs("ContentTypeID")
  700. user_id = rs("user_id")
  701. ContentID = rs("ContentID")
  702. ContentType = rs("ContentType")
  703. Cat = rs("Cat")
  704. Title = rs("Title")
  705. Author = rs("Author")
  706. DateAdded = rs("DateAdded")
  707. ShortDesc = rs("ShortDesc")
  708. Display = rs("Display")
  709. Priority = rs("Priority")
  710. Impressions = rs("Impressions")
  711. ClickThrus = rs("ClickThrus")
  712. AvgRating = rs("AvgRating")
  713. on error goto 0
  714.  
  715. %>
  716.         
  717.         <input type=hidden name="CatID" value="<% =CatID %>">
  718.         
  719.         
  720.         <input type=hidden name="ContentTypeID" value="<% =ContentTypeID %>">
  721.         
  722.         
  723.         <input type=hidden name="user_id" value="<% =user_id %>">
  724.         
  725. <tr>
  726.     <td class='dataTD' >
  727.         <a href="admin_content.asp?ContentID=<%=ContentID%>"><% =ContentID %></a>
  728.     </td>
  729.     <td class='dataTD' nowrap>
  730.         <% =ContentType %>
  731.     </td>
  732.     <td class='dataTD' nowrap>
  733.         <% =Cat %>
  734.     </td>
  735.     <td class='dataTD' >
  736.         <a href="admin_content.asp?ContentID=<%=ContentID%>"><% =Title %></a>
  737.     </td>
  738.     <td class='dataTD' >
  739.         <% if user_id <> "" then %>[<a href='admin_users.asp?user_id=<% =user_id %>'><% end if %><% =Author %><% if user_id <> "" then %></A>]<% end if %>
  740.     </td>
  741.     <td class='dataTD' width=140 nowrap>
  742.         <% =DateAdded %>
  743.     </td>
  744.     <td class='dataTD' >
  745.         <% ShortDesc = left(ShortDesc,55) %><% =ShortDesc %>...
  746.     </td>
  747.     <td class='dataTD' >
  748.         <% =Display %>
  749.     </td>
  750.     <td class='dataTD' >
  751.         <% =Priority %>
  752.     </td>
  753.     <td class='dataTD' >
  754.         <% =Impressions %>
  755.     </td>
  756.     <td class='dataTD' >
  757.         <% =ClickThrus %>
  758.     </td>
  759.     <td class='dataTD' >
  760.         <% =AvgRating %>
  761.     </td>
  762. </tr>
  763. <%
  764.  
  765. rs.MoveNext
  766. rec_count = rec_count + 1
  767. loop
  768. rs.Close
  769.  
  770. %>
  771.  
  772. </form>
  773. </table>
  774. <%
  775.  
  776. else
  777.  
  778. %>
  779.  
  780.     no matches were found.
  781.  
  782. <%
  783.  
  784. end if
  785.  
  786. %>
  787.  
  788. <%
  789.  if max_count > 1 then 
  790. %>
  791.  
  792. <!-- paging footer -->
  793. <TABLE class=HeaderTable >
  794.     <tr>
  795.         <td width="20%" class=HeaderTD>
  796.             <% if page_no > 1 then %>
  797.             <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no-1 %>&sortby=<% =request("sortby") %>">PREV</a>
  798.             <% else %>            <% end if %>        </td>
  799.         <td align=center class=HeaderTD>
  800.             Page 
  801.             <% for i = 1 to max_count %>
  802.             <% if i = cint(page_no) then %>
  803.             <b><%=i%></b>
  804.             <% else %>
  805.             <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =i %>&sortby=<% =request("sortby") %>"><%=i%></a>
  806.             <% end if %>
  807.             <%next %>
  808.         </td>
  809.         <td align=right width="20%" class=HeaderTD>
  810.             <% if cInt(page_no) < cInt(max_count) then %>
  811.             <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no+1 %>&sortby=<% =request("sortby") %>">NEXT</a>
  812.             <% end if %>
  813.         </td>
  814.     </tr>
  815. </TABLE>
  816. <% end if %>
  817.  
  818.  
  819. <% end if %>
  820.  
  821. <!-- #include file=i_footer.asp -->
  822.  
  823.  
  824. <%
  825. ':: assure that any db resources are freed
  826. on error resume next
  827. rs.Close
  828. set rs = NOTHING
  829. cn.Close
  830. set cn = NOTHING
  831. user_cn.Close
  832. set user_cn = NOTHING
  833. on error goto 0
  834. %>
  835.